//
//  STProductHandle.m
//  CuiBoStore
//
//  Created by 崔博 on 16/12/8.
//  Copyright © 2016年 崔博. All rights reserved.
//

#import "STProductHandle.h"
#import "STProductBannerModel.h"
#import "STProduceTitleDataModel.h"
#import "STProdataListModel.h"

NSString *const KProductDetailBannerImageArray = @"KProductDetailBannerImageArray";
NSString *const KProductDetailBottomImageArray = @"KProductDetailBottomImageArray";

@implementation STProductHandle
+ (void)excuteProducBannerGoodsId:(NSString *)goodsId sucess:(SucessBlock)sucess failed:(FailedBlock)failed
{
    NSDictionary *dic = @{@"GoodsId":goodsId};
    [HttpTool postWithPath:PRODUCTBANNER params:dic success:^(id json) {
        NSArray *array = [STProductBannerModel mj_objectArrayWithKeyValuesArray:json];
        NSMutableArray *topArray = [NSMutableArray array];
        for (STProductBannerModel *m in array) {
            if ([m.ImgType isEqualToString:@"1"]) {
                [topArray addObject:m];
            }
        }
        
        NSDictionary *dic = @{KProductDetailBannerImageArray:array,
                              KProductDetailBottomImageArray:topArray};
        sucess(dic);
    } failure:^(NSError *error) {
        
    }];
}
+ (void)excuteProductTitleDataGoodsId:(NSString *)goodsId sucess:(SucessBlock)sucess failed:(FailedBlock)failed
{
    NSDictionary *dic = @{@"GoodsId":goodsId};
    [HttpTool postWithPath:PRODUCTDETAILLIST params:dic success:^(id json) {
        STProduceTitleDataModel *m = [STProduceTitleDataModel mj_objectWithKeyValues:json];
        sucess(m);
    } failure:^(NSError *error) {
        
    }];
}

+ (void)excutProductList:(NSString *)goodsId sucess:(SucessBlock)sucess failed:(FailedBlock)failed
{
    NSDictionary *dic = @{@"GoodsId":goodsId};
    [HttpTool getWithPath:PRODUCTLIST params:dic success:^(id json) {
        NSArray *list = [STProdataListModel mj_objectArrayWithKeyValuesArray:json];
        sucess(list);
    } failure:^(NSError *error) {
        
    }];
}
@end
